<?php

	class Devmod_method_save extends Devmod_methods_abstraction {
		
		public function set_config($args) {}
		
		public function operation_edit()
		{
			return $this->config[$this->type]['sql_fields'];
		}
		
		public function operation_del()
		{
			return $this->config[$this->type]['where'];	
		}
		
		public function operation_add()
		{
			return $this->config[$this->type]['sql_fields'];	
		}
		
		public function operation_frontend_add()
		{
			return $this->config[$this->type]['sql_fields'];	
		}
		
		public function finalize_edit($args)
		{
			if($args === false) return false;
			
			foreach($args as $k => $v)
			{
				$args[$k] = htmlentities(utf8_decode($v), ENT_QUOTES);
			}
			
			return $this->db->handler($this->config['sql_table'], $args, "WHERE " . $this->config[$this->type]['where']);
		}
		
		public function finalize_del($args)
		{
			if($args === false) return false;
			
			return $this->db->delete($this->config['sql_table'], $args);
		}
		
		public function finalize_add($args)
		{
			if($args === false) return false;
			
			foreach($args as $k => $v)
			{
				$args[$k] = $this->helper->decode_save($v);
			}
			return $this->db->handler($this->config['sql_table'], $args, false);
		}
		
		public function finalize_frontend_add($args)
		{
			if($args === false) return false;
			
			foreach($args as $k => $v)
			{
				$args[$k] = $this->helper->decode_save($v);
			}
			
			return $this->db->handler($this->config['sql_table'], $args, false);
		}
		
	}